package com.abc.wy.utils;

import com.abc.wy.fdp.exception.IErrorCode;

import java.util.HashMap;

public class ResponseMsg extends HashMap<String, Object> {

    public ResponseMsg() {
        put("code", 0);
        put("message", "success");
    }

    public static ResponseMsg ok() {
        ResponseMsg responseMsg = new ResponseMsg();
        responseMsg.put("code", 0);
        responseMsg.put("message", "success");
        return responseMsg;
    }

    public static ResponseMsg ok(Object data) {
        ResponseMsg responseMsg = new ResponseMsg();
        responseMsg.put("code", 0);
        responseMsg.put("message", "success");
        responseMsg.put("data", data);
        return responseMsg;
    }

    public static ResponseMsg error(IErrorCode errorCode) {
        ResponseMsg responseMsg = new ResponseMsg();
        responseMsg.put("code", errorCode.getCode());
        responseMsg.put("errorMessage", errorCode.getErrorMessage());
        responseMsg.put("userMessage", errorCode.getUserMessage());
        return responseMsg;
    }
}
